package com.mylove.judas.yaya.common.exception;

import android.content.Context;

import com.mylove.judas.yaya.R;


/**
 * Created by Administrator on 2017/5/26 0026.
 */
public class ErrorMessageFactory {


    /**
     * 根据code对应Error信息
     * @param mContext
     * @param code
     * @return
     */
    public static String create(Context mContext, int code){

        String message = "";

        switch (code) {

            case BaseException.ERROR_SOCKET:
                message = mContext.getResources().getString(R.string.error_socket);
                break;
            case BaseException.ERROR_SOCKET_TIMEOUT:
                message = mContext.getResources().getString(R.string.error_socket_timeout);
                break;
            case BaseException.ERROR_JSONPARSE:
                message = mContext.getResources().getString(R.string.error_jsonparse);
                break;
            case BaseException.ERROR_HTTP_400:
                message = mContext.getResources().getString(R.string.error_http_400);
                break;
            case BaseException.ERROR_HTTP_404:
                message = mContext.getResources().getString(R.string.error_http_404);
                break;
            case BaseException.ERROR_HTTP_405:
                message = mContext.getResources().getString(R.string.error_http_405);
                break;
            case BaseException.ERROR_HTTP_500:
                message = mContext.getResources().getString(R.string.error_http_500);
                break;
            case BaseException.ERROR_UNKNOW:
                message = mContext.getResources().getString(R.string.error_unknow);
                break;

        }

        return message;

    }

}
